﻿// CMyLoginDialog.cpp: 实现文件
//

#include "pch.h"
#include "MFC对话框.h"
#include "afxdialogex.h"
#include "CMyLoginDialog.h"
#include "MFC对话框Dlg.h"


// CMyLoginDialog 对话框

IMPLEMENT_DYNAMIC(CMyLoginDialog, CDialogEx)

CMyLoginDialog::CMyLoginDialog(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_LOGIN, pParent)
{

}

CMyLoginDialog::~CMyLoginDialog()
{
}

void CMyLoginDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CMyLoginDialog, CDialogEx)
	ON_BN_CLICKED(IDOK, &CMyLoginDialog::OnBnClickedOk)
END_MESSAGE_MAP()


// CMyLoginDialog 消息处理程序


void CMyLoginDialog::OnBnClickedOk()	//CMyLoginDialog对话框窗口的登录按钮跳转函数
{
	/*
	//跳转到CMyChat对话框窗口：
	CMyChat dlg;
	dlg.DoModal();

	CDialogEx::OnOK();
	*/


	//登录条件出发跳转对话框函数：
	wchar_t username[256];
	wchar_t userpassword[256];

	::GetDlgItemText(m_hWnd/*当前窗口句柄*/, IDC_USERPASSWORD, userpassword, 256);
	::GetDlgItemText(m_hWnd/*当前窗口句柄*/, IDC_USERNAME, username, 256);

	CString user = username;
	CString pass = userpassword;

	if ("admin" == user && "6" == pass)
	{
		/*
		CMyChat dlg;
		dlg.DoModal();
		*/
		CDialogEx::OnOK();	//结束当前对话框

		CMFC对话框Dlg dlg;
		dlg.DoModal();

		
	}
	else if ("admin" == user && "6" != pass)
	{
		MessageBox(L"密码输入错误！");
	}
	else
	{
		MessageBox(L"用户不存在!");
	}


}
